<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../VueJs/vue.js"></script>
    <script src="../VueJs/dayjs.min.js"></script>
</head>

<body>
    <div id="root">
        <h1>显示格式化后的时间</h1>
        <h2>{{formatTime}}</h2>
    </div>
</body>
<script>
    Vue.config.productionTip = false;
    Vue.config.devtools = true;

    const vm = new Vue({
        el: '#root',
        data: {
            time: Date.now()
        },
        computed: {
            formatTime: {
                get() {
                    return dayjs(this.time).format('YYYY-MM-DD HH:mm:ss');
                }
            }
        }
    });
</script>

</html>